﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using ZX.SYS.Library;
using ZX.SYS.Bussiness.DeskTop;
using Newtonsoft.Json;
using ZX.Web.UI.Controls;

namespace ZX.WebApp.DeskTop.SetDesktop
{
    /// <summary>
    /// 角色桌面修改
    /// </summary>
    public partial class ModifyDeskTop : System.Web.UI.Page
    {
        private string action = string.Empty;
        private string RoleDesktopID = string.Empty;
        private string RoleID = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            action = Request["Oper"];
            switch (action)
            {
                case "Modify": Modify(); break;
            }
            if (!IsPostBack)
            {
                RoleDesktopID = Request["RoleDesktopID"];
                RoleID = Request["RoleID"];
                LoadData();
            }
        }

        protected void LoadData()
        {
            SysRoleDesktop srt = new SysRoleDesktop();
            srt = BDeskTop.GetRoleDesktopEntity(RoleDesktopID);
            txtDeskName.Value =srt.DeskTopName;
            txtPath.Value = srt.Src;
            txtHeight.Value = srt.Height;
            ddlPageType.SelectedIndex = srt.PageType;
        }

        protected void Modify()
        {
            RoleID = Request["RoleID"];
            RoleDesktopID = Request["RoleDesktopID"];
            string Src = Request["Src"];
            string DeskTopName = Request["DeskTopName"];
            string Height = Request["Height"];
            string PageType = Request["PageType"];

            SysRoleDesktop srt = new SysRoleDesktop();
            srt = BDeskTop.GetRoleDesktopEntity(RoleDesktopID);
            srt.Src = Src;
            srt.DeskTopName = DeskTopName;
            srt.Height = Height;
            srt.PageType = int.Parse(PageType);
            srt.Update();

            string json = JsonConvert.SerializeObject("保存成功");
            Response.Clear();
            Response.ContentType = "application/json";
            Response.Write(json);
            Response.End();
        }
    }
}